<div class="g-doc_select_pic">
	<div class="picbox_desc">
		Choose the one both you and your friend’s favour!!
	</div>
	<div class="picbox_icon_prev" id="pre">
	</div>
	<form action="/game-selectfriends" id="selectfriends_form" method="get">
	<div class="picbox ibox">
		<div class="showbox">
		<ul>
			<?php foreach ($this->pictures as $p):?>
				<li>
					<img class="picture" alt="<?php echo $p['Picture_Title']?>" picid="<?php echo $p['Picture_ID']?>" src="<?php echo $p['Picture_Url']?>" />
					<span class="title">
						<a class="a_t" href="<?php if($this->link): echo $this->link.$p['Picture_ID']; else:?>http://www.newjerseysoccer.net/pd-<?php echo $p['Picture_ID']?>.html<?php endif; ?>" target="_blank"><?php echo $p['Picture_Title']?></a><br />
						<a class="a_i" href="<?php if($this->link): echo $this->link.$p['Picture_ID']; else:?>http://www.newjerseysoccer.net/pd-<?php echo $p['Picture_ID']?>.html<?php endif; ?>" target="_blank"><img src="../images/game/buy_now.png" height="18" /></a>
					</span>
				</li>
			<?php endforeach;?>
		</ul>
        </div>
	</div>
	<input type="hidden" value="<?php echo $this->f ?>" name="f" />
	<input type="hidden" value="" name="picid" id="picid" />
	<input type="hidden" value="<?php echo $this->signed_request;?>" name="signed_request" />
	</form>
	<div class="picbox_icon_next" id="next">
	</div>
<script type="text/javascript">
$(function(){
	document.onselectstart=new Function("event.returnValue=false;");
	var $cur = 1;
	var $i = 1;
	var $len = $('.showbox>ul>li').length;
	var $pages = Math.ceil($len / $i);
	var $w = $('.ibox').width();
	var $showbox = $('.showbox');
	var $pre = $('#pre');
	var $next = $('#next');
	var $animatespeed = 400;
	$pre.click(function(){
		if (!$showbox.is(':animated')) {
			if ($cur == 1) {
				$showbox.animate({left: '-=' + $w * ($pages - 1)},$animatespeed);
				$cur = $pages;
			}
			else {
				$showbox.animate({left: '+=' + $w},$animatespeed);
				$cur--;
			}
		}
	});
	$next.click(function(){
		if (!$showbox.is(':animated')) {
			if ($cur == $pages) {
				$showbox.animate({left: 0},$animatespeed);
				$cur = 1;
			}
			else {
				$showbox.animate({left: '-=' + $w},$animatespeed);
				$cur++;
			}
		}
	});
	$(".picture").each(function(){
		$(this).click(function(){
			$("#picid").val($(this).attr("picid"));
			$("#selectfriends_form").submit();
		});
	});
});
</script>
